<?php

//  This example script extends what was explained in the previous one by demonstrating more features



// Before running, check the paths in the demo_initialization file
include('demo_initialization.php');




$form1 = new Imp($smarty);         // one default imp is allowed, and his handle in smarty (the "imp" parameter in any form tag) defaults to 'puck'
$form2 = new Imp($smarty, 'form2'); // all other imps must explicitly be given names
$form3 = new Imp($smarty, 'form3');

// First, I'll define some invalidators.  If these rules fire, the form will go back to the user for checking
$puck->invalidator('model_exists', 'empty'       , array(imp_oot('model')   ));
$puck->invalidator('model_exists', 'longer_than' , array(imp_oot('model'), 5));
$puck->invalidator('must_agree'  , 'empty'       , array(imp_oot('agree')   ));
// Since those validation functions were not valid in the global namespace, they automatically searched the library of functions in the imp namespace




// here, i'll check if the form was submitted
if( $default->submitted() ){
  echo'YOU HAVE SUBMITTED THIS FORM...<BR/>';
  if( $default->validate() ){
    echo 'AND IT WAS VALID!';
    exit();
  }
  ECHO 'BUT THERE WERE ERRORS:<BR/>';
}



$smarty->display('multi_form.tpl');

?>
